Skip to content

Show a runnable example in each crate README and make it the crate doc - #302

Merged
soareschen merged 4 commits into
mainfrom
crate-readme-examples
Nov 16, 2026
Merged

soareschen merged 4 commits into
mainfrom
crate-readme-examples

Conversation

@soareschen

@soareschen soareschen commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Overview

[claude-opus-5-5] Most crate READMEs now show a short program using the crate's main construct, and each of those READMEs is also its crate's documentation, so crates.io and docs.rs show the same text. Before this PR, the crate docs held a sentence and a list of reference links, and most READMEs described the crate in a paragraph without an example.

Each README also places its crate in CGP. It names Context-Generic Programming in a sentence about what the crate does, and closes with how a project reaches the crate through cgp, which reference pages cover it, and where to learn CGP itself. The cgp README quotes the cargo cgp check qualification in the wording the other documents use.

Approach

The examples are not doctests, because each one goes through the cgp crate, which the crate it documents cannot depend on. They are marked rust,ignore, and each compiles and runs against this tree on stable. The error backends' three examples also run as tests in cgp-tests, and they are now complete programs ending in fn main() rather than statements at the top level.

Areas needing attention

  • crates/tests/cgp-tests/build.rs now takes the body of fn main() in each error backend's README example as the test body, where it took the statements after the last item before. A block without that shape fails the build with the README's path.

soareschen and others added 4 commits November 16, 2026 23:17
The READMEs of the 14 crates a reader may land on directly (the core
and extra layers, their component crates, and the macro crates) now
open with what CGP is, show a short program using the crate's main
construct through the cgp crate, and keep the reference-page links their
lib.rs docs listed. Each README is now its crate's documentation
through include_str!, so docs.rs and crates.io show one text.

The examples are marked rust,ignore, as the error backends' are: each
uses the cgp crate, which the crate itself cannot depend on. Each
example compiled and ran against this tree before the change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The READMEs with an example relate CGP's tag line to the crate's own
part rather than repeating one opening sentence, and introduce their
reference links as what the website's reference covers. Every README
closes on the same pointer to the website and the cgp crate's API. The
error backends name Context-Generic Programming in full, drop their
License sections as the other crates' READMEs do, and split two
semicolon-joined sentences; cgp-macro-test-util's README loses its bold
emphasis and jargon.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…examples as written

The crate READMEs opened with one sentence pasted onto fourteen of them. Each opening now names
Context-Generic Programming in a sentence about what that crate does, relating the idea of
pluggable trait implementations to it, or leaving it out where it does not fit, as with the async
trait macro.

The error backends' examples ran their statements at the top level, which is not Rust a reader can
copy; they now sit in `fn main()`, and the test crate's build script takes the body of `main` as
the test it generates from each README. The `cgp` README quotes the checker's qualification as the
other documents do, and the snapshot-test macros' README names CGP, splits its long opening
sentence, labels its layout block as text, and wraps its prose at 100 columns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The READMEs of the crates `cgp` re-exports ended with three single-sentence paragraphs, on the
reference pages, on reaching the crate through `cgp`, and on the website, each starting fresh. They
now read as two connected paragraphs: how a project reaches the crate and which reference pages
cover it, then where to learn CGP itself. The small internal crates' READMEs read the same way,
`cgp-core` and `cgp-extra` open with sentences that lead into their examples, and the error backends
introduce their provider tables and join the short sentences about `String` errors and `std`
features.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@soareschen
soareschen marked this pull request as ready for review November 16, 2026 22:47
@soareschen
soareschen merged commit 1c11cb0 into main Nov 16, 2026
6 checks passed
@soareschen
soareschen deleted the crate-readme-examples branch November 16, 2026 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant